# Copyright (C) 2012-2015 Free Software Foundation, Inc.

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  

#
# i386 tests
#
proc gas_64_check { } {
    global NM
    global NMFLAGS

    set status [gas_host_run "$NM $NMFLAGS --help" ""]
    return [regexp "targets:.*x86-64" [lindex $status 1]];
}

proc gas_32_check { } {
    global NM
    global NMFLAGS

    set status [gas_host_run "$NM $NMFLAGS --help" ""]
    return [regexp "targets:.*i386" [lindex $status 1]];
}

if [expr ([istarget "i*86-*-*"] ||  [istarget "x86_64-*-*"]) && [gas_32_check]]  then {

    global ASFLAGS
    set old_ASFLAGS "$ASFLAGS"
    set ASFLAGS "$ASFLAGS --32"

    run_list_test "float" "-al -mmnemonic=att"
    run_list_test "general" "-al --listing-lhs-width=2 -mold-gcc"
    run_list_test "inval" "-al"
    run_list_test "inval-16" "-al"
    run_list_test "segment" "-al"
    run_list_test "inval-seg" "-al"
    run_list_test "inval-reg" "-al"
    run_list_test "modrm" "-al --listing-lhs-width=2"
    run_dump_test "naked"
    run_dump_test "opcode"
    run_dump_test "opcode-intel"
    run_dump_test "opcode-suffix"
    run_dump_test "intel"
    run_dump_test "intel16"
    run_list_test "intelbad" ""
    run_dump_test "intelok"
    run_dump_test "prefix"
    run_dump_test "amd"
    run_dump_test "katmai"
    run_dump_test "jump"
    run_dump_test "relax-1"
    run_dump_test "relax-2"
    run_dump_test "ssemmx2"
    run_dump_test "sse2"
    run_dump_test "sub"
    run_dump_test "sse3"
    run_dump_test "sib"
    run_dump_test "sib-intel"
    run_dump_test "disp"
    run_dump_test "disp-intel"
    run_dump_test "disp32"
    run_dump_test "vmx"
    run_dump_test "vmfunc"
    run_dump_test "smx"
    run_dump_test "suffix"
    run_dump_test "suffix-intel"
    run_dump_test "immed32"
    run_dump_test "equ"
    run_dump_test "divide"
    run_dump_test "padlock"
    run_dump_test "crx"
    run_list_test "cr-err" ""
    run_dump_test "cdr"
    run_dump_test "svme"
    run_dump_test "amdfam10"
    run_dump_test "ssse3"
    run_dump_test "rep"
    run_dump_test "rep-suffix"
    run_list_test "inval-rep" "-al"
    run_dump_test "lock-1"
    run_dump_test "lock-1-intel"
    run_list_test "lockbad-1" "-al"
    run_dump_test "long-1"
    run_dump_test "long-1-intel"
    run_dump_test "fp"
    run_dump_test "nops"
    run_dump_test "nops16-1"
    run_dump_test "nops-1"
    run_dump_test "nops-1-i386"
    run_dump_test "nops-1-i386-i686"
    run_dump_test "nops-1-i686"
    run_dump_test "nops-1-k8"
    run_dump_test "nops-1-core2"
    run_dump_test "nops-2"
    run_dump_test "nops-2-i386"
    run_dump_test "nops-2-core2"
    run_dump_test "nops-3"
    run_dump_test "nops-3-i386"
    run_dump_test "nops-3-i686"
    run_dump_test "nops-4"
    run_dump_test "nops-4-i386"
    run_dump_test "nops-4-i686"
    run_dump_test "nops-4a-i686"
    run_dump_test "nops-5"
    run_dump_test "nops-5-i686"
    run_dump_test "nops-6"
    run_dump_test "addr16"
    run_dump_test "addr32"
    run_dump_test "sse4_1"
    run_dump_test "sse4_1-intel"
    run_dump_test "sse4_2"
    run_dump_test "sse4_2-intel"
    run_dump_test "crc32"
    run_dump_test "crc32-intel"
    run_list_test "inval-crc32" "-al"
    run_dump_test "simd"
    run_dump_test "simd-intel"
    run_dump_test "simd-suffix"
    run_dump_test "mem"
    run_dump_test "mem-intel"
    run_dump_test "reg"
    run_dump_test "reg-intel"
    run_dump_test "i386"
    run_dump_test "i386-intel"
    run_dump_test "compat"
    run_dump_test "compat-intel"
    run_dump_test "arch-1"
    run_dump_test "arch-2"
    run_dump_test "arch-3"
    run_dump_test "arch-4"
    run_dump_test "arch-5"
    run_dump_test "arch-6"
    run_dump_test "arch-7"
    run_dump_test "arch-9"
    run_dump_test "arch-10"
    run_dump_test "arch-10-lzcnt"
    run_dump_test "arch-10-prefetchw"
    run_dump_test "arch-10-bdver1"
    run_dump_test "arch-10-bdver2"
    run_dump_test "arch-10-bdver3"
    run_dump_test "arch-10-bdver4"
    run_dump_test "arch-13-znver1"
    run_dump_test "arch-10-btver1"
    run_dump_test "arch-10-btver2"
    run_list_test "arch-10-1" "-march=generic32 -I${srcdir}/$subdir -al"
    run_list_test "arch-10-2" "-march=i686 -I${srcdir}/$subdir -al"
    run_list_test "arch-10-3" "-march=i686+sse4.2 -I${srcdir}/$subdir -al"
    run_list_test "arch-10-4" "-march=i686+sse4+vmx+smx -I${srcdir}/$subdir -al"
    run_dump_test "arch-11"
    run_dump_test "arch-12"
    run_dump_test "arch-13"
    run_dump_test "8087"
    run_dump_test "287"
    run_dump_test "387"
    run_list_test "no87" "-al"
    run_list_test "no87-2" "-march=i686+no87 -al"
    run_dump_test "xsave"
    run_dump_test "xsave-intel"
    run_dump_test "aes"
    run_dump_test "aes-intel"
    run_dump_test "clmul"
    run_dump_test "clmul-intel"
    run_dump_test "avx"
    run_dump_test "avx-intel"
    run_dump_test "avx-scalar"
    run_dump_test "avx-scalar-intel"
    run_dump_test "avx256int"
    run_dump_test "avx256int-intel"
    run_dump_test "avx2"
    run_dump_test "avx2-intel"
    run_dump_test "avx-gather"
    run_dump_test "avx-gather-intel"
    run_dump_test "avx512f"
    run_dump_test "avx512f-intel"
    run_dump_test "avx512f-opts"
    run_dump_test "avx512f-opts-intel"
    run_dump_test "avx512f-nondef"
    run_dump_test "avx512cd"
    run_dump_test "avx512cd-intel"
    run_dump_test "avx512er"
    run_dump_test "avx512er-intel"
    run_dump_test "avx512pf"
    run_dump_test "avx512pf-intel"
    run_dump_test "evex-lig256"
    run_dump_test "evex-lig512"
    run_dump_test "evex-lig256-intel"
    run_dump_test "evex-lig512-intel"
    run_dump_test "evex-wig1"
    run_dump_test "evex-wig1-intel"
    run_dump_test "sse2avx"
    run_list_test "inval-avx" "-al"
    run_list_test "inval-avx512f" "-al"
    run_dump_test "sse-check"
    run_dump_test "sse-check-none"
    run_dump_test "sse-check-warn"
    run_list_test "sse-check-error" "-msse-check=error -I${srcdir}/$subdir -al"
    run_dump_test "vgather-check"
    run_dump_test "vgather-check-none"
    run_dump_test "vgather-check-warn"
    run_list_test "vgather-check-error" "-moperand-check=error -I${srcdir}/$subdir"
    run_dump_test "sse-noavx"
    run_dump_test "movbe"
    run_dump_test "movbe-intel"
    run_list_test "inval-movbe" "-al"
    run_dump_test "ept"
    run_dump_test "ept-intel"
    run_list_test "inval-ept" "-al"
    run_dump_test "invpcid"
    run_dump_test "invpcid-intel"
    run_list_test "inval-invpcid" "-al"
    run_dump_test "arch-avx-1"
    run_list_test "arch-avx-1-1" "-march=generic32+avx -I${srcdir}/$subdir -al"
    run_list_test "arch-avx-1-2" "-march=generic32+aes -I${srcdir}/$subdir -al"
    run_list_test "arch-avx-1-3" "-march=generic32+pclmul -I${srcdir}/$subdir -al"
    run_list_test "arch-avx-1-4" "-march=generic32+avx+aes -I${srcdir}/$subdir -al"
    run_list_test "arch-avx-1-5" "-march=generic32+avx+pclmul -I${srcdir}/$subdir -al"
    run_list_test "arch-avx-1-6" "-march=generic32+aes+pclmul -I${srcdir}/$subdir -al"
    run_dump_test "opts"
    run_dump_test "opts-intel"
    run_dump_test "sse2avx-opts"
    run_dump_test "sse2avx-opts-intel"
    run_dump_test "bmi2"
    run_dump_test "bmi2-intel"
    run_dump_test "fma"
    run_dump_test "fma-intel"
    run_dump_test "fma-scalar"
    run_dump_test "fma-scalar-intel"
    run_dump_test "hle"
    run_dump_test "hle-intel"
    run_list_test "hlebad" "-al"
    run_dump_test "rtm"
    run_dump_test "rtm-intel"
    run_dump_test "fma4"
    run_dump_test "lwp"
    run_dump_test "xop"
    run_dump_test "bmi"
    run_dump_test "bmi-intel"
    run_dump_test "tbm"
    run_dump_test "tbm-intel"
    run_dump_test "f16c"
    run_dump_test "f16c-intel"
    run_dump_test "fsgs"
    run_dump_test "fsgs-intel"
    run_dump_test "rdrnd"
    run_dump_test "rdrnd-intel"
    run_dump_test "bundle"
    run_dump_test "bundle-lock"
    run_dump_test "bundle-bad"
    run_dump_test "adx"
    run_dump_test "adx-intel"
    run_dump_test "rdseed"
    run_dump_test "rdseed-intel"
    run_dump_test "prefetch"
    run_dump_test "prefetch-intel"
    run_dump_test "smap"
    run_dump_test "mpx"
    run_list_test "mpx-inval-1" "-al"
    run_dump_test "mpx-add-bnd-prefix"
    run_dump_test "sha"
    run_dump_test "clflushopt"
    run_dump_test "clflushopt-intel"
    run_dump_test "xsavec"
    run_dump_test "xsavec-intel"
    run_dump_test "xsaves"
    run_dump_test "xsaves-intel"
    run_dump_test "prefetchwt1"
    run_dump_test "prefetchwt1-intel"
    run_dump_test "se1"
    run_dump_test "avx512f_vl-intel"
    run_dump_test "avx512f_vl-opts-intel"
    run_dump_test "avx512f_vl-opts"
    run_dump_test "avx512f_vl-wig1-intel"
    run_dump_test "avx512f_vl-wig1"
    run_dump_test "avx512f_vl"
    run_dump_test "avx512cd_vl-intel"
    run_dump_test "avx512cd_vl"
    run_dump_test "avx512bw-intel"
    run_dump_test "avx512bw-opts-intel"
    run_dump_test "avx512bw-opts"
    run_dump_test "avx512bw-wig1-intel"
    run_dump_test "avx512bw-wig1"
    run_dump_test "avx512bw"
    run_dump_test "avx512bw_vl-intel"
    run_dump_test "avx512bw_vl-opts-intel"
    run_dump_test "avx512bw_vl-opts"
    run_dump_test "avx512bw_vl-wig1-intel"
    run_dump_test "avx512bw_vl-wig1"
    run_dump_test "avx512bw_vl"
    run_dump_test "avx512dq-intel"
    run_dump_test "avx512dq"
    run_dump_test "avx512dq_vl-intel"
    run_dump_test "avx512dq_vl"
    run_dump_test "omit-lock-yes"
    run_dump_test "omit-lock-no"
    run_dump_test "avx512dq-rcigrd-intel"
    run_dump_test "avx512dq-rcigrd"
    run_dump_test "avx512dq-rcigrne-intel"
    run_dump_test "avx512dq-rcigrne"
    run_dump_test "avx512dq-rcigru-intel"
    run_dump_test "avx512dq-rcigru"
    run_dump_test "avx512dq-rcigrz-intel"
    run_dump_test "avx512dq-rcigrz"
    run_dump_test "avx512er-rcigrd-intel"
    run_dump_test "avx512er-rcigrd"
    run_dump_test "avx512er-rcigrne-intel"
    run_dump_test "avx512er-rcigrne"
    run_dump_test "avx512er-rcigru-intel"
    run_dump_test "avx512er-rcigru"
    run_dump_test "avx512er-rcigrz-intel"
    run_dump_test "avx512er-rcigrz"
    run_dump_test "avx512f-rcigrd-intel"
    run_dump_test "avx512f-rcigrd"
    run_dump_test "avx512f-rcigrne-intel"
    run_dump_test "avx512f-rcigrne"
    run_dump_test "avx512f-rcigru-intel"
    run_dump_test "avx512f-rcigru"
    run_dump_test "avx512f-rcigrz-intel"
    run_dump_test "avx512f-rcigrz"
    run_dump_test "clwb"
    run_dump_test "clwb-intel"
    run_dump_test "pcommit"
    run_dump_test "pcommit-intel"
    run_dump_test "avx512ifma"
    run_dump_test "avx512ifma-intel"
    run_dump_test "avx512ifma_vl"
    run_dump_test "avx512ifma_vl-intel"
    run_dump_test "avx512vbmi"
    run_dump_test "avx512vbmi-intel"
    run_dump_test "avx512vbmi_vl"
    run_dump_test "avx512vbmi_vl-intel"
    run_dump_test "clzero"
    run_dump_test "disassem"
    run_dump_test "mwaitx-bdver4"
    run_list_test "mwaitx-reg"

    # These tests require support for 8 and 16 bit relocs,
    # so we only run them for ELF and COFF targets.
    if {[is_elf_format] || [istarget "*-*-coff*"]} then {
	run_dump_test "reloc"
	run_dump_test "jump16"
	run_list_test "white" "-al --listing-lhs-width=3"

	# These tests should in theory work for PE targets as well,
	# but the relocs we currently produce are slightly different
	# from those produced for ELF/COFF based toolchains.
	# So for now we ignore PE targets.
	run_dump_test "absrel"
	if {[istarget "*-*-coff*"]} then {
	    run_dump_test "pcrel"
	}
    }

    # ELF specific tests
    if [is_elf_format] then {
	# PIC is only supported on ELF targets.
	run_dump_test "intelpic"

	run_dump_test "pcrel-elf"
	run_dump_test "relax"
	run_dump_test "gotpc"
	run_dump_test "tlsd"
	run_dump_test "tlspic"
	run_dump_test "tlsnopic"
	run_dump_test "bss"
	run_dump_test "reloc32"
	run_list_test "reloc32" "--defsym _bad_=1"
	run_dump_test "mixed-mode-reloc32"
	run_dump_test "att-regs"
	run_dump_test "intel-got32"
	run_dump_test "intel-regs"
	run_list_test "inval-equ-1" "-al"
	run_list_test "inval-equ-2" "-al"
	run_dump_test "ifunc"
	run_list_test "ifunc-2"
	run_dump_test "ifunc-3"
	run_list_test "l1om-inval" "-march=l1om --32"
	run_list_test "k1om-inval" "-march=k1om --32"
	run_dump_test "localpic"
	run_dump_test "debug1"

	run_dump_test "dw2-compress-2"
	run_dump_test "dw2-compressed-2"

	run_dump_test "bad-size"

	run_dump_test "size-1"
	run_dump_test "size-2"
	run_dump_test "size-3"
	run_dump_test "size-4"

	run_dump_test "note"

	run_dump_test "relax-3"
	run_dump_test "relax-4"

	if {![istarget "*-*-nacl*"]} then {
	    run_dump_test "iamcu-1"
	    run_dump_test "iamcu-2"
	    run_dump_test "iamcu-3"
	    run_list_test "iamcu-inval-1" "-march=iamcu -al"
	    run_list_test "iamcu-inval-2" "-march=iamcu -al"
	    run_list_test "iamcu-inval-3" "-march=iamcu+sse4 -al"
	}
    }

    # This is a PE specific test.
    if { [istarget "*-*-cygwin*"] || [istarget "*-*-pe"]
	 || [istarget "*-*-mingw*"]
    } then {
	run_dump_test "secrel"
    }

    # Miscellaneous tests.
    run_dump_test "pr12589-1"

    set ASFLAGS "$old_ASFLAGS"
}

# Common tests
if [expr [istarget "i*86-*-*"] || [istarget "x86_64-*-*"]] then {
    if {![istarget "i*86-*-elfiamcu"]} then {
	run_dump_test "intel-expr"
	run_dump_test "string-ok"
    }
    run_list_test "string-bad" ""
    run_list_test "reg-bad" ""
    run_list_test "space1" "-al"
    run_dump_test rept
    if [is_elf_format] then {
	run_list_test_stdin "list-1" "-al"
	run_list_test_stdin "list-2" "-al"
	run_list_test_stdin "list-3" "-al"
	run_dump_test "dw2-compress-1"
	run_dump_test "dw2-compress-3"
	run_dump_test "dw2-compressed-1"
	run_dump_test "dw2-compressed-3"
    }
}

if [expr ([istarget "i*86-*-*"] || [istarget "x86_64-*-*"]) && [gas_64_check]] then {

    global ASFLAGS
    set old_ASFLAGS "$ASFLAGS"
    set ASFLAGS "$ASFLAGS --64"

    run_dump_test "x86_64"
    run_dump_test "x86_64-intel"
    run_dump_test "x86-64-addr32"
    run_dump_test "x86-64-addr32-intel"
    run_dump_test "x86-64-opcode"
    run_dump_test "x86-64-intel64"
    if { ![istarget "*-*-mingw*"] } then {
      run_dump_test "x86-64-pcrel"
      run_dump_test "x86-64-disassem"
    } else {
      run_dump_test "x86-64-w64-pcrel"
    }
    run_dump_test "x86-64-rip"
    run_dump_test "x86-64-rip-intel"
    run_dump_test "x86-64-stack"
    run_dump_test "x86-64-stack-intel"
    run_dump_test "x86-64-stack-suffix"
    run_list_test "x86-64-inval" "-al"
    run_list_test "x86-64-segment" "-al"
    run_dump_test "x86-64-segovr"
    run_list_test "x86-64-inval-seg" "-al"
    run_dump_test "x86-64-branch"
    run_dump_test "x86-64-relax-1"
    run_dump_test "svme64"
    run_dump_test "x86-64-amdfam10"
    run_dump_test "x86-64-vmx"
    run_dump_test "x86-64-vmfunc"
    run_dump_test "immed64"
    run_dump_test "x86-64-sse3"
    run_dump_test "x86-64-crx"
    run_dump_test "x86-64-crx-suffix"
    run_dump_test "x86-64-drx"
    run_dump_test "x86-64-drx-suffix"
    run_dump_test "x86-64-cdr"
    run_dump_test "x86-64-ssse3"
    run_dump_test "x86-64-rep"
    run_dump_test "x86-64-rep-suffix"
    run_list_test "x86-64-inval-rep" "-al"
    run_dump_test "x86-64-lock-1"
    run_dump_test "x86-64-lock-1-intel"
    run_list_test "x86-64-lockbad-1" "-al"
    run_dump_test "x86-64-long-1"
    run_dump_test "x86-64-long-1-intel"
    run_dump_test "x86-64-cbw"
    run_dump_test "x86-64-cbw-intel"
    run_dump_test "x86-64-io"
    run_dump_test "x86-64-io-intel"
    run_dump_test "x86-64-io-suffix"
    run_dump_test "x86-64-gidt"
    run_dump_test "x86-64-nops"
    run_dump_test "x86-64-nops-1"
    run_dump_test "x86-64-nops-1-g64"
    run_dump_test "x86-64-nops-1-k8"
    run_dump_test "x86-64-nops-1-core2"
    run_dump_test "x86-64-nops-1-pentium"
    run_dump_test "x86-64-nops-2"
    run_dump_test "x86-64-nops-3"
    run_dump_test "x86-64-nops-4"
    run_dump_test "x86-64-nops-4-core2"
    run_dump_test "x86-64-nops-4-k8"
    run_dump_test "x86-64-nops-5"
    run_dump_test "x86-64-nops-5-k8"
    run_dump_test "x86-64-sse4_1"
    run_dump_test "x86-64-sse4_1-intel"
    run_dump_test "x86-64-sse4_2"
    run_dump_test "x86-64-sse4_2-intel"
    run_dump_test "x86-64-crc32"
    run_dump_test "x86-64-crc32-intel"
    run_list_test "x86-64-inval-crc32" "-al"
    run_dump_test "x86-64-simd"
    run_dump_test "x86-64-simd-intel"
    run_dump_test "x86-64-simd-suffix"
    run_dump_test "x86-64-mem"
    run_dump_test "x86-64-mem-intel"
    run_dump_test "x86-64-reg"
    run_dump_test "x86-64-reg-intel"
    run_dump_test "x86-64-sib"
    run_dump_test "x86-64-sib-intel"
    run_dump_test "x86-64-disp"
    run_dump_test "x86-64-disp-intel"
    run_dump_test "x86-64-disp32"
    run_dump_test "rexw"
    run_list_test "x86-64-specific-reg"
    run_list_test "x86-64-suffix-bad"
    run_dump_test "x86-64-fxsave"
    run_dump_test "x86-64-fxsave-intel"
    run_dump_test "x86-64-arch-1"
    run_dump_test "x86-64-arch-2"
    run_dump_test "x86-64-arch-3"
    run_dump_test "x86-64-arch-2-lzcnt"
    run_dump_test "x86-64-arch-2-prefetchw"
    run_dump_test "x86-64-arch-2-bdver1"
    run_dump_test "x86-64-arch-2-bdver2"
    run_dump_test "x86-64-arch-2-bdver3"
    run_dump_test "x86-64-arch-2-bdver4"
    run_dump_test "x86-64-arch-3-znver1"
    run_dump_test "x86-64-arch-2-btver1"
    run_dump_test "x86-64-arch-2-btver2"
    run_list_test "x86-64-arch-2-1" "-march=generic64 -I${srcdir}/$subdir -al"
    run_list_test "x86-64-arch-2-2" "-march=generic64+cx16 -I${srcdir}/$subdir -al"
    run_dump_test "x86-64-xsave"
    run_dump_test "x86-64-xsave-intel"
    run_dump_test "x86-64-aes"
    run_dump_test "x86-64-aes-intel"
    run_dump_test "x86-64-clmul"
    run_dump_test "x86-64-clmul-intel"
    run_dump_test "x86-64-avx"
    run_dump_test "x86-64-avx-intel"
    run_dump_test "x86-64-avx-scalar"
    run_dump_test "x86-64-avx-scalar-intel"
    run_dump_test "x86-64-avx256int"
    run_dump_test "x86-64-avx256int-intel"
    run_dump_test "x86-64-avx2"
    run_dump_test "x86-64-avx2-intel"
    run_dump_test "x86-64-avx-gather"
    run_dump_test "x86-64-avx-gather-intel"
    run_dump_test "x86-64-avx512f"
    run_dump_test "x86-64-avx512f-intel"
    run_dump_test "x86-64-avx512f-opts"
    run_dump_test "x86-64-avx512f-opts-intel"
    run_dump_test "x86-64-avx512f-nondef"
    run_dump_test "x86-64-avx512cd"
    run_dump_test "x86-64-avx512cd-intel"
    run_dump_test "x86-64-avx512er"
    run_dump_test "x86-64-avx512er-intel"
    run_dump_test "x86-64-avx512pf"
    run_dump_test "x86-64-avx512pf-intel"
    run_dump_test "x86-64-evex-lig256"
    run_dump_test "x86-64-evex-lig512"
    run_dump_test "x86-64-evex-lig256-intel"
    run_dump_test "x86-64-evex-lig512-intel"
    run_dump_test "x86-64-evex-wig1"
    run_dump_test "x86-64-evex-wig1-intel"
    run_dump_test "x86-64-sse2avx"
    run_list_test "x86-64-inval-avx" "-al"
    run_list_test "x86-64-inval-avx512f" "-al"
    run_dump_test "x86-64-sse-check"
    run_dump_test "x86-64-sse-check-none"
    run_dump_test "x86-64-sse-check-warn"
    run_list_test "x86-64-sse-check-error" "-msse-check=error -I${srcdir}/$subdir -al"
    run_dump_test "x86-64-vgather-check"
    run_dump_test "x86-64-vgather-check-none"
    run_dump_test "x86-64-vgather-check-warn"
    run_list_test "x86-64-vgather-check-error" "-moperand-check=error -I${srcdir}/$subdir"
    run_dump_test "x86-64-sse-noavx"
    run_dump_test "x86-64-movbe"
    run_dump_test "x86-64-movbe-intel"
    run_list_test "x86-64-inval-movbe" "-al"
    run_dump_test "x86-64-ept"
    run_dump_test "x86-64-ept-intel"
    run_list_test "x86-64-inval-ept" "-al"
    run_dump_test "x86-64-invpcid"
    run_dump_test "x86-64-invpcid-intel"
    run_list_test "x86-64-inval-invpcid" "-al"
    run_dump_test "x86-64-opts"
    run_dump_test "x86-64-opts-intel"
    run_dump_test "x86-64-sse2avx-opts"
    run_dump_test "x86-64-sse2avx-opts-intel"
    run_dump_test "x86-64-avx-swap"
    run_dump_test "x86-64-avx-swap-intel"
    run_dump_test "x86-64-bmi2"
    run_dump_test "x86-64-bmi2-intel"
    run_dump_test "x86-64-fma"
    run_dump_test "x86-64-fma-intel"
    run_dump_test "x86-64-fma-scalar"
    run_dump_test "x86-64-fma-scalar-intel"
    run_dump_test "x86-64-hle"
    run_dump_test "x86-64-hle-intel"
    run_list_test "x86-64-hlebad" "-al"
    run_dump_test "x86-64-rtm"
    run_dump_test "x86-64-rtm-intel"
    run_dump_test "x86-64-fma4"
    run_dump_test "x86-64-lwp"
    run_dump_test "x86-64-xop"
    run_dump_test "x86-64-bmi"
    run_dump_test "x86-64-bmi-intel"
    run_dump_test "x86-64-tbm"
    run_dump_test "x86-64-tbm-intel"
    run_dump_test "x86-64-f16c"
    run_dump_test "x86-64-f16c-intel"
    run_dump_test "x86-64-fsgs"
    run_dump_test "x86-64-fsgs-intel"
    run_dump_test "x86-64-rdrnd"
    run_dump_test "x86-64-rdrnd-intel"
    run_dump_test "x86-64-bundle"
    run_dump_test "x86-64-adx"
    run_dump_test "x86-64-adx-intel"
    run_dump_test "x86-64-rdseed"
    run_dump_test "x86-64-rdseed-intel"
    run_dump_test "x86-64-prefetch"
    run_dump_test "x86-64-prefetch-intel"
    run_dump_test "x86-64-smap"
    run_dump_test "x86-64-mpx"
    run_list_test "x86-64-mpx-inval-1" "-al"
    run_list_test "x86-64-mpx-inval-2" "-al"
    run_dump_test "x86-64-mpx-addr32"
    run_dump_test "x86-64-mpx-add-bnd-prefix"
    run_dump_test "x86-64-sha"
    run_dump_test "x86-64-clflushopt"
    run_dump_test "x86-64-clflushopt-intel"
    run_dump_test "x86-64-xsavec"
    run_dump_test "x86-64-xsavec-intel"
    run_dump_test "x86-64-xsaves"
    run_dump_test "x86-64-xsaves-intel"
    run_dump_test "x86-64-prefetchwt1"
    run_dump_test "x86-64-prefetchwt1-intel"
    run_dump_test "x86-64-se1"
    run_dump_test "x86-64-equ"
    run_dump_test "x86-64-avx512f_vl-intel"
    run_dump_test "x86-64-avx512f_vl-opts-intel"
    run_dump_test "x86-64-avx512f_vl-opts"
    run_dump_test "x86-64-avx512f_vl-wig1-intel"
    run_dump_test "x86-64-avx512f_vl-wig1"
    run_dump_test "x86-64-avx512f_vl"
    run_dump_test "x86-64-avx512cd_vl-intel"
    run_dump_test "x86-64-avx512cd_vl"
    run_dump_test "x86-64-avx512bw-intel"
    run_dump_test "x86-64-avx512bw-opts-intel"
    run_dump_test "x86-64-avx512bw-opts"
    run_dump_test "x86-64-avx512bw-wig1-intel"
    run_dump_test "x86-64-avx512bw-wig1"
    run_dump_test "x86-64-avx512bw"
    run_dump_test "x86-64-avx512bw_vl-intel"
    run_dump_test "x86-64-avx512bw_vl-opts-intel"
    run_dump_test "x86-64-avx512bw_vl-opts"
    run_dump_test "x86-64-avx512bw_vl-wig1-intel"
    run_dump_test "x86-64-avx512bw_vl-wig1"
    run_dump_test "x86-64-avx512bw_vl"
    run_dump_test "x86-64-avx512dq-intel"
    run_dump_test "x86-64-avx512dq"
    run_dump_test "x86-64-avx512dq_vl-intel"
    run_dump_test "x86-64-avx512dq_vl"
    run_dump_test "x86-64-suffix"
    run_dump_test "x86-64-suffix-intel"
    run_dump_test "x86-64-avx512dq-rcigrd-intel"
    run_dump_test "x86-64-avx512dq-rcigrd"
    run_dump_test "x86-64-avx512dq-rcigrne-intel"
    run_dump_test "x86-64-avx512dq-rcigrne"
    run_dump_test "x86-64-avx512dq-rcigru-intel"
    run_dump_test "x86-64-avx512dq-rcigru"
    run_dump_test "x86-64-avx512dq-rcigrz-intel"
    run_dump_test "x86-64-avx512dq-rcigrz"
    run_dump_test "x86-64-avx512er-rcigrd-intel"
    run_dump_test "x86-64-avx512er-rcigrd"
    run_dump_test "x86-64-avx512er-rcigrne-intel"
    run_dump_test "x86-64-avx512er-rcigrne"
    run_dump_test "x86-64-avx512er-rcigru-intel"
    run_dump_test "x86-64-avx512er-rcigru"
    run_dump_test "x86-64-avx512er-rcigrz-intel"
    run_dump_test "x86-64-avx512er-rcigrz"
    run_dump_test "x86-64-avx512f-rcigrd-intel"
    run_dump_test "x86-64-avx512f-rcigrd"
    run_dump_test "x86-64-avx512f-rcigrne-intel"
    run_dump_test "x86-64-avx512f-rcigrne"
    run_dump_test "x86-64-avx512f-rcigru-intel"
    run_dump_test "x86-64-avx512f-rcigru"
    run_dump_test "x86-64-avx512f-rcigrz-intel"
    run_dump_test "x86-64-avx512f-rcigrz"
    run_dump_test "x86-64-clwb"
    run_dump_test "x86-64-clwb-intel"
    run_dump_test "x86-64-pcommit"
    run_dump_test "x86-64-pcommit-intel"
    run_dump_test "x86-64-avx512ifma"
    run_dump_test "x86-64-avx512ifma-intel"
    run_dump_test "x86-64-avx512ifma_vl"
    run_dump_test "x86-64-avx512ifma_vl-intel"
    run_dump_test "x86-64-avx512vbmi"
    run_dump_test "x86-64-avx512vbmi-intel"
    run_dump_test "x86-64-avx512vbmi_vl"
    run_dump_test "x86-64-avx512vbmi_vl-intel"
    run_dump_test "x86-64-clzero"
    run_dump_test "x86-64-mwaitx-bdver4"
    run_list_test "x86-64-mwaitx-reg"

    if { ![istarget "*-*-aix*"]
      && ![istarget "*-*-beos*"]
      && ![istarget "*-*-*bsd*"]
      && ![istarget "*-*-chaos*"]
      && ![istarget "*-*-kaos*"]
      && ![istarget "*-*-lynx*"]
      && ![istarget "*-*-moss*"]
      && ![istarget "*-*-nto-qnx*"]
      && ![istarget "*-*-rtems*"]
      && ![istarget "*-*-sco*"]
      && ![istarget "*-*-solaris*"]
      && ![istarget "*-*-sysv*"] } then {
	run_dump_test "rex"
    }

    # ELF specific tests
    if [is_elf_format] then {
	# Verify that @unwind works.
	run_dump_test "x86-64-unwind"

	run_dump_test "reloc64"
	run_list_test "reloc64" "--defsym _bad_=1"
	run_dump_test "mixed-mode-reloc64"
	run_dump_test "x86-64-ifunc"
	run_dump_test "x86-64-opcode-inval"
	run_dump_test "x86-64-opcode-inval-intel"
	run_dump_test "intel-got64"
	run_dump_test "l1om"
	run_dump_test "k1om"
	run_dump_test "x86-64-localpic"
	run_dump_test "debug1"
	run_dump_test "x86-64-mpx-branch-1"
	run_dump_test "x86-64-mpx-branch-2"

	run_dump_test "x86-64-dw2-compress-2"
	run_dump_test "x86-64-dw2-compressed-2"

	run_dump_test "x86-64-size-1"
	run_dump_test "x86-64-size-2"
	run_dump_test "x86-64-size-3"
	run_dump_test "x86-64-size-4"
	run_dump_test "x86-64-size-5"
	run_list_test "x86-64-size-inval-1" "-al"

	run_dump_test "x86-64-relax-2"
	run_dump_test "x86-64-relax-3"

	run_dump_test "x86-64-jump"
	run_dump_test "x86-64-branch-2"
	run_list_test "x86-64-branch-3" "-al -mintel64"
    }

    set ASFLAGS "$old_ASFLAGS"
}
